#overall_plots
#data prep for response quality plots


##for main text plot (combined surveys and avg coefficients across tests)

##arrange order for plot here:
input1 <- reg13
input2 <- reg2
input3 <- reg3
input4 <- reg1i 
input5 <- effort.out
input6 <- reg12
input7 <- quality.out
input8 <- reg14
input9 <- reg9
input10 <- reg6
input11 <- att.out

#input numbers of regressions that need to be reverse coded here:
reverse.list <- c(4,8,10)

#function for standardized regressions
my.fun <- function(fit){
  as.data.frame(std_beta(fit, type = "std", ci.lvl = 0.95)[1, ] )
  }


frame <- rbind(my.fun(input1), my.fun(input2), my.fun(input3), my.fun(input4), my.fun(input5), 
               my.fun(input6), my.fun(input7), my.fun(input8), my.fun(input9), my.fun(input10),
               my.fun(input11))
  
for(i in 1:length(reverse.list)){
  i <- reverse.list[i]
frame$std.estimate[i] <-  frame$std.estimate[i] * -1
newhigh <- frame$conf.low[i] * -1
newlow <- frame$conf.high[i] * -1
frame$conf.low[i] <- newlow
frame$conf.high[i] <- newhigh
}


names_avgs <- c( "answering open-ended items", "reading prompt", "answering short items", "straightlining" , "response effort", "response length", "response quality",  "commital answers", "consistency", "skipping", "attention check" )
dimension_avgs <- c("time investment", "time investment", "time investment","straightlining", "open-ended", "open-ended", "open-ended", "commital",  "consistency", "skipping" , "attention check" )
order_avgs <- 1:11
betas_avgs<- cbind(dimension_avgs, names_avgs, order_avgs, frame)



##for appendix plot (separate out different surveys)

##arrange order for plot here:
input1 <- reg5
input2 <- reg4
input3 <- reg2
input4 <- reg3
input5 <- reg1i 
input6 <- effort.out
input7 <- reg11 
input8 <- reg10
input9 <- quality.out
input10 <- reg8
input11 <- reg7
input12 <- reg9
input13 <- reg6
input14 <- att.out

#input numbers of regressions that need to be reverse coded here:
reverse.list <- c(5, 10, 11, 13)

frame <- rbind(my.fun(input1), my.fun(input2), my.fun(input3), my.fun(input4), my.fun(input5), 
               my.fun(input6), my.fun(input7), my.fun(input8), my.fun(input9), my.fun(input10),
               my.fun(input11), my.fun(input12), my.fun(input13), my.fun(input14))

for(i in 1:length(reverse.list)){
  i <- reverse.list[i]
  frame$std.estimate[i] <-  frame$std.estimate[i] * -1
  newhigh <- frame$conf.low[i] * -1
  newlow <- frame$conf.high[i] * -1
  frame$conf.low[i] <- newlow
  frame$conf.high[i] <- newhigh
}

names <- c( "answering open-ended 2", "answering open-ended 1", "reading prompt", "answering short items", "straightlining", "response effort", "question 2 length", "question 1 length" , "response quality",  "question 2 answer",  "question 1 answer", "consistency", "skipping", "attention check" )
dimension <- c("time investment", "time investment", "time investment", "time investment", "straightlining", "open-ended", "open-ended", "open-ended", "open-ended", "commital", "commital", "consistency", "skipping", "attention check")
order <- 1:14
betas<- cbind(dimension, names, order, frame)

#repeat for FEP and Sec versions
##arrange order for plot here:
input1 <- reg5.f
input2 <- reg4.f
input3 <- reg2.f
input4 <- reg3.f
input5 <- reg1i.f
input6 <- effort.out.f
input7 <- reg11.f
input8 <- reg10.f
input9 <- quality.out.f
input10 <- reg8.f
input11 <- reg7.f
input12 <- reg9.f
input13 <- reg6.f
input14 <- att.out

#input numbers of regressions that need to be reverse coded here:
reverse.list <- c(5, 10, 11, 13)

frame <- rbind(my.fun(input1), my.fun(input2), my.fun(input3), my.fun(input4), my.fun(input5), 
               my.fun(input6), my.fun(input7), my.fun(input8), my.fun(input9), my.fun(input10),
               my.fun(input11), my.fun(input12), my.fun(input13), my.fun(input14))

for(i in 1:length(reverse.list)){
  i <- reverse.list[i]
  frame$std.estimate[i] <-  frame$std.estimate[i] * -1
  newhigh <- frame$conf.low[i] * -1
  newlow <- frame$conf.high[i] * -1
  frame$conf.low[i] <- newlow
  frame$conf.high[i] <- newhigh
}

betas.f<- cbind(dimension, names, order, frame)


##arrange order for plot here:
input1 <- reg5.s
input2 <- reg4.s
input3 <- reg2.s
input4 <- reg3.s
input5 <- reg1i.s
input6 <- effort.out.s
input7 <- reg11.s
input8 <- reg10.s
input9 <- quality.out.s
input10 <- reg8.s
input11 <- reg7.s
input12 <- reg9.s
input13 <- reg6.s
input14 <- att.out

#input numbers of regressions that need to be reverse coded here:
reverse.list <- c(5, 10, 11, 13)

frame <- rbind(my.fun(input1), my.fun(input2), my.fun(input3), my.fun(input4), my.fun(input5), 
               my.fun(input6), my.fun(input7), my.fun(input8), my.fun(input9), my.fun(input10),
               my.fun(input11), my.fun(input12), my.fun(input13), my.fun(input14))

for(i in 1:length(reverse.list)){
  i <- reverse.list[i]
  frame$std.estimate[i] <-  frame$std.estimate[i] * -1
  newhigh <- frame$conf.low[i] * -1
  newlow <- frame$conf.high[i] * -1
  frame$conf.low[i] <- newlow
  frame$conf.high[i] <- newhigh
}

betas.s<- cbind(dimension, names, order, frame)
